<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/include/common/formbackhead.jsp"%>
<%!
private class PageAction extends BaseAction{
	ResultSet rs = null;
	
	//准备action的环境变量 每次请次都会执行此方法 可在此方法中初如化一些变量
	protected void prepareActionEnv() throws Exception{
		
	}
	
	//加載頁面默認數據
	protected boolean onLoadDefault() throws Exception{
		if(!form.isNullOrEmpty("wfname")){
			onSearchRetrieveResult();
		}
		return true ;
	}
	
	// 取出查询結果
	protected void onSearchRetrieveResult() throws Exception{
		String sql = onSearchGetSql();
		if(sql == null){ret.setErrorInfo("查询语句异常,请联系资讯部!");return;}
		rs = utils.executeQuery("info5",sql);
		ret.SetSearchResult(rs);
	}

	//取出查詢語句
	protected String onSearchGetSql() throws Exception{
		StringBuilderEx sql =  new StringBuilderEx("select a.sn as wfopstepid ,b.wf002sn as wfstepid, c.checkpage, b.wfname ,"
		+" b.wfbillno,b.wfdatakeyvalue,"
		+" case a.isfinsh when 0 then a.wfstepname else '登陸人員確認' end as wfstepname, b.sendday,b.sendchname,b.sendhrnum "
		+" from wf..wf004 a, "
		+"wf..wf001 c, wf..wf003 b left join "
		+" (select a.sn ,count(b.sn) as cnt from pan..PAN_SUBPRO_APPIP a, pan..PAN_SUBPRO_APPHRNUM b"
		+" where a.sn = b.applySn and b.status = 1"
		+" group by a.sn) d on b.wfdatakeyvalue = d.sn"
		+" where a.wf003sn = b.sn and a.wf003version = b.version and b.wf001sn = c.sn and c.sn = 12 and (a.isfinsh = 0 or d.cnt > 0) ");
		sql.Append(" and a.ophrnum = '%1$s'",utils.getHrNum());
		
		if(!form.isNullOrEmpty("wfname")){
			sql.Append(" and b.wfname = '%1$s'",form.gpsv("wfname"));
		}
		
		if(!form.isNullOrEmpty("whr")){
			sql.Append(form.gpsv("whr"));
		}
		sql.Append(" order by a.crtday desc ");
		return sql.toString();
	}
}
%>
<%@include file="/include/common/formbackend.jsp"%>
